<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <canvas id="canvas" width="400" height="420"></canvas>
    <video src="https://www.w3school.com.cn/i/movie.ogg" controls></video>
</body>
<script>
    var canvas = document.getElementById('canvas')
    var video = document.getElementsByTagName('video')[0]
    console.log(video)

    var intId = null
    var ctx = canvas.getContext('2d');
    video.onplay = function() {
        intId = setInterval(function(){
            ctx.clearRect(50,0,320,340)
            ctx.fillRect(50,0, 320, 340)

            ctx.strokeStyle = '#fff'
            ctx.strokeText('mystic', 50, 50)

            ctx.drawImage(video, 50,50,320,240)
        }, 16)
    }

    video.onpause = function() {
        clearInterval(intId)
    }
    


</script>
</html>